package com.ruoyi.cms.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.core.domain.BaseSelect;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cms.mapper.CmsHelpCategoryMapper;
import com.ruoyi.cms.domain.CmsHelpCategory;
import com.ruoyi.cms.service.ICmsHelpCategoryService;

/**
 * 帮助文档分类Service业务层处理
 * 
 * @author zouhuu
 * @date 2022-08-04
 */
@Service
public class CmsHelpCategoryServiceImpl implements ICmsHelpCategoryService 
{
    @Autowired
    private CmsHelpCategoryMapper cmsHelpCategoryMapper;

    /**
     * 查询帮助文档分类选项
     *
     * @param cmsHelpCategory 帮助文档分类
     * @return 帮助文档分类集合
     */
    @Override
    public List<BaseSelect> selectCmsHelpCategoryOptions(CmsHelpCategory cmsHelpCategory) {
        List<BaseSelect> collect = cmsHelpCategoryMapper.selectCmsHelpCategoryOptions(cmsHelpCategory)
                .stream()
                .map(item -> new BaseSelect(item.getId(), item.getName()))
                .collect(Collectors.toList());
        return collect;
    }

    /**
     * 查询帮助文档分类
     * 
     * @param id 帮助文档分类主键
     * @return 帮助文档分类
     */
    @Override
    public CmsHelpCategory selectCmsHelpCategoryById(Long id)
    {
        return cmsHelpCategoryMapper.selectCmsHelpCategoryById(id);
    }

    /**
     * 查询帮助文档分类列表
     * 
     * @param cmsHelpCategory 帮助文档分类
     * @return 帮助文档分类
     */
    @Override
    public List<CmsHelpCategory> selectCmsHelpCategoryList(CmsHelpCategory cmsHelpCategory)
    {
        return cmsHelpCategoryMapper.selectCmsHelpCategoryList(cmsHelpCategory);
    }

    /**
     * 新增帮助文档分类
     * 
     * @param cmsHelpCategory 帮助文档分类
     * @return 结果
     */
    @Override
    public int insertCmsHelpCategory(CmsHelpCategory cmsHelpCategory)
    {
        cmsHelpCategory.setCreateTime(DateUtils.getNowDate());
        return cmsHelpCategoryMapper.insertCmsHelpCategory(cmsHelpCategory);
    }

    /**
     * 修改帮助文档分类
     * 
     * @param cmsHelpCategory 帮助文档分类
     * @return 结果
     */
    @Override
    public int updateCmsHelpCategory(CmsHelpCategory cmsHelpCategory)
    {
        cmsHelpCategory.setUpdateTime(DateUtils.getNowDate());
        return cmsHelpCategoryMapper.updateCmsHelpCategory(cmsHelpCategory);
    }

    /**
     * 批量删除帮助文档分类
     * 
     * @param ids 需要删除的帮助文档分类主键
     * @return 结果
     */
    @Override
    public int deleteCmsHelpCategoryByIds(Long[] ids)
    {
        return cmsHelpCategoryMapper.deleteCmsHelpCategoryByIds(ids);
    }

    /**
     * 删除帮助文档分类信息
     * 
     * @param id 帮助文档分类主键
     * @return 结果
     */
    @Override
    public int deleteCmsHelpCategoryById(Long id)
    {
        return cmsHelpCategoryMapper.deleteCmsHelpCategoryById(id);
    }
}
